import idraw.*;
import geometry.*;
import tester.*;
import java.util.*;
import colors.*;

class WholeGameWorld extends World{
	Mfmwg genie;
	ILoS stars;

	// produce a walker heading in the direction given by the key
	public void onKeyEvent(String ke){
		if (this.stars.foundStar(this.genie)){
			this.genie.onKeyEvent(ke);
		    this.genie.catchStar(this.stars.caughtStar(this.genie));
		}
		else this.genie.onKeyEvent(ke);
	}

	//ticks the world once and updates all things.
	public void onTick(){
		if(this.genie.fuel <=0) { 
			endOfWorld("you're out of fuel, fool!");
		} else {
			this.genie.onTick();
			this.stars.onTick(this.genie); 
		}
	}

	//draws the whole wide world.
	public void draw(){
		this.genie.drawMfmwg(this.theCanvas);
		this.stars.drawStars(this.theCanvas);

	}

	public static void main(String[] argv){
		// construct an instance of a TimerWorld
		Examples w = new Examples();
		// and run the TimerWorld
		w.go();
	}

	WholeGameWorld(Mfmwg genie, ILoS stars) {
		this.genie = genie;
		this.stars = stars;
	}
	/*
TEMPLATE:
   FIELDS:
    ... this.genie ...            --Mfmwg
    ... this.stars ...            --ILoS

    METHODS:
    ... this.onKeyEvent() ...      -- World
    ... this.onTick) ...           -- World
    ... this.draw() ...            -- boolean

    METHODS FOR FIELDS:
    ... this.stars.drawStars(Canvas c) ...  -- boolean
    ... this.stars.onTick(Mfmwg m) ...      -- ILoS
    ... this.stars.foundStar(Mfmwg m) ...   -- boolean
    ... this.stars.caughtStar(Mfmwg m) ...  -- boolean
    ... this.genie.drawMfmwg(Canvas c) ...  -- boolean
    ... this.genie.catchStar() ...          -- Mfmwg
    ... this.genie.onKeyEvent(String ke) ...-- Mfmwg
    ... this.genie.onTick() ...             -- Mfmwg
	 */ 
}